package com.smarthome.web.property.controller.statisticsquery;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smarthome.core.statisticsquery.PropertyStatisticsService;
import com.smarthome.domain.bean.ShService;
import com.smarthome.domain.vo.boss.TimeRange;
import com.smarthome.web.property.utils.UserHolder;

/**
 * 物业服务统计控制类
 * @author cyj
 *
 */
@Controller
@RequestMapping("/propertyStatisticsController")
public class PropertyStatisticsController {

    @Resource
    private PropertyStatisticsService propertyStatisticsService;
    

    
    
    /**
     * 
    * @Title: getStatisticsData 
    * @Description: TODO(获取物业统计数据) 
    * @return
    * Map<String,Object>
    * @throws 
    * @author cyj
     */
    @RequestMapping("/getStatisticsData")
    @ResponseBody
    public Map<String,Object> getStatisticsData(TimeRange timeRange) {
    	Map<String,Object> result = new HashMap<>();
    	ShService queryService = new ShService();
    	if(timeRange.getStartGmtCreate() != null) {
    		queryService.addQueryData("startGmtCreate", timeRange.getStartGmtCreate());
    	}
    	if(timeRange.getEndGmtCreate() != null) {
    		queryService.addQueryData("endGmtCreate", timeRange.getEndGmtCreate());
    	}
    	queryService.setResidenceId(UserHolder.getCurrentResidenceId());
    	result = propertyStatisticsService.getStatisticsData(queryService);
    	return result;
    }
}
